'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 弱点
 * @author sundbcn@gmail.com (sun debing)
 */

var _ = require('lodash');

/**
 * 获取弱点
 * @param  {[type]} soldier_type [description]
 * @param  {[type]} soldier_lv   [description]
 * @return {[type]}              [description]
 */
exports.getAttr = function (weakness_conf_info) {
    var weakness_list = [];
    if (!_.isString(weakness_conf_info)) {
        console.error('need string');
        return weakness_list;
    }
    if (weakness_conf_info.length <= 0) {
        return weakness_list;
    }
    var weakness_conf_list = weakness_conf_info.split(',');
    _.each(weakness_conf_list, function (weakness_conf) {
        var weakness_type = parseInt(weakness_conf.split(':')[0]);
        var weakness_value = parseInt(weakness_conf.split(':')[1]);
        if (!!weakness_type && !!weakness_value) {
            weakness_list.push({
                weakness_type: weakness_type,
                weakness_value: weakness_value
            });
        }
    });
    return weakness_list;
};
